package com.hanxiaozhang.no3algorithm;

/**
 * 〈一句话功能简述〉<br>
 * 〈找出最大利润〉
 *
 * @author hanxinghua
 * @create 2020/5/23
 * @since 1.0.0
 */
public class No2Example {

    public static void main(String[] args) {

    }


    public static int maxProfit(int[] table) {
        int len = table.length;
        if (len == 0 || len == 1) {
            return 0;
        }
        int maxProfit = 0;
        for (int i = 0; i < len - 1; i++) {
            int price = table[i];
            for (int j = i + 1; j < len; j++) {
                int profit = table[j] - price;
                if (profit > maxProfit) {
                    maxProfit = profit;
                }
            }
        }
        return maxProfit;
    }


}
